package com.delistry.database;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.delistry.server.Account;
import com.delistry.server.utils.SQLUtil;

public class DatabaseInsertor {
	public static void InsertAccount(Account account) {

		Connection conn = null;
		PreparedStatement ps = null;

		try {
			conn = DatabaseFactory.getInstance().getConnection();

			String commandSql = InsertCommand();// "insert into account_delisty set id = ?,password = ?";

			ps = conn.prepareStatement(commandSql);

			ps.setString(1, "abc");
			ps.setString(2, "qqq");

			ps.execute();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			SQLUtil.close(conn);
			SQLUtil.close(ps);
		}

	}

	private static String InsertCommand() {
		String cmd = "";

		String table = "account_delisty";
		String table_account = "id", table_pw = "password";

		cmd = String.format("insert into %s set %s = ?,%s = ?", table,
				table_account, table_pw);
		return cmd;
	}
}
